package com.线程池;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyThreadPoolDemp {


    public static void main(String[] args) {
        //1.创建线程池对象
        ExecutorService pool1= Executors.newCachedThreadPool();//获取没有上线的线程池对象
        ExecutorService pool2= Executors.newFixedThreadPool(3);//有上限的线程池对象

        //提交任务,MyRunnable的对象
        pool1.submit(new MyRunnable());


        /*
        pool1.submit(new MyRunnable());
        pool1.submit(new MyRunnable());
        pool1.submit(new MyRunnable());
        pool1.submit(new MyRunnable());
        pool1.submit(new MyRunnable());  最多名称出现3*/
        //销毁线程池
        pool1.shutdown();


    }
}
